package com.wtwd.wtwddevice.service.impl;


import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wtwd.wtwddevice.mapper.DeviceHeartRateTotalMapper;
import com.wtwd.wtwddevice.model.entity.DeviceHeartRateTotal;
import com.wtwd.wtwddevice.service.IDeviceHeartRateTotalService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author mjy
 * @since 2024-05-27
 */
@Service
public class DeviceHeartRateTotalServiceImpl extends ServiceImpl<DeviceHeartRateTotalMapper, DeviceHeartRateTotal> implements IDeviceHeartRateTotalService {


    @Resource
    private DeviceHeartRateTotalMapper deviceHeartRateTotalMapper;


    @Override
    public Boolean insertOrUpdate(DeviceHeartRateTotal heartRateTotal) {
        if (heartRateTotal == null) {
            return false;
        }
        return deviceHeartRateTotalMapper.insertOrUpdate(heartRateTotal);
    }

    @Override
    public DeviceHeartRateTotal getDeviceHeartRateTotal(Long deviceId, String time) {
        return new LambdaQueryChainWrapper<>(deviceHeartRateTotalMapper)
                .eq(DeviceHeartRateTotal::getDeviceId, deviceId)
                .eq(DeviceHeartRateTotal::getTime, time)
                .one();
    }
}
